Skip to content

feat: Add UpdateToken #2474

Open
aceppaluni wants to merge 3 commits into
hiero-ledger:mainfrom
aceppaluni:updatetoken
Open

feat: Add UpdateToken #2474
aceppaluni wants to merge 3 commits into
hiero-ledger:mainfrom
aceppaluni:updatetoken

Conversation

@aceppaluni

Copy link
Copy Markdown
Contributor

Description:

Implements the updateToken JSON-RPC endpoint in the TCK module by adding the required parameter, response, and handler layers following the existing token transaction conventions.

The new endpoint integrates through the existing @rpc_method registration flow and does not require any server, protocol, or handler registration changes.

Changes

Parameter layer

  • Added UpdateTokenParams in tck/param/token.py.

  • Added support for all TokenUpdateTransaction fields exposed by the TCK surface:

    • tokenId
    • token metadata fields (name, symbol, memo, metadata)
    • account fields (treasuryAccountId, autoRenewAccountId)
    • key fields (adminKey, kycKey, freezeKey, wipeKey, supplyKey, feeScheduleKey, pauseKey, metadataKey)
    • lifecycle fields (expirationTime, autoRenewPeriod)
  • Kept key, expiration, and auto-renew values as raw strings in params, matching existing createToken conventions and deferring conversion to the handler layer.

  • Intentionally omitted keyVerificationMode to align with the resolved TCK parameter surface.

Response layer

  • Added UpdateTokenResponse as a StatusOnlyResponse.
  • Matches existing status-only token transaction responses such as DeleteTokenResponse, FreezeTokenResponse, and PauseTokenResponse.

Handler layer

  • Added TokenUpdateTransaction support.

  • Added _build_update_token_transaction() to construct update transactions with:

    • default gRPC timeout configuration
    • conditional setter application only for provided fields
    • existing TCK conversion conventions for IDs, keys, timestamps, and durations
  • Added the updateToken RPC handler:

    • retrieves the client from the session
    • applies common transaction parameters
    • executes without waiting for receipt
    • validates the receipt status
    • returns the mapped ResponseCode

Related issue(s):

Fixes #2397

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

Signed-off-by: aceppaluni <aceppaluni@gmail.com>
@aceppaluni
aceppaluni requested a review from a team as a code owner July 22, 2026 19:01
@aceppaluni
aceppaluni requested a review from MonaaEid July 22, 2026 19:01
@github-actions github-actions Bot added approved Issue has been approved by team member scope: TCK involves engineering for the implementation of TCK method and module skill: advanced requires knowledge of multiple areas in the codebase without defined steps to implement or examples labels Jul 22, 2026
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2c9ecd9b-613a-42bc-809e-facb3eaf2fbc

📥 Commits

Reviewing files that changed from the base of the PR and between 42d17d4 and 847235b.

📒 Files selected for processing (1)
  • tck/handlers/token.py

Walkthrough

Adds the updateToken RPC endpoint to the TCK module, including request parsing, token update transaction construction, transaction execution, receipt validation, and status response modeling.

Changes

Token Update RPC

Layer / File(s) Summary
Update token request and response contracts
tck/param/token.py, tck/response/token.py
Adds UpdateTokenParams with token fields and JSON-RPC parsing, plus the UpdateTokenResponse status payload.
Update token transaction execution
tck/handlers/token.py
Builds and executes TokenUpdateTransaction, applies common transaction parameters, validates the receipt, and returns the response status.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant update_token
  participant TokenUpdateTransaction
  participant HederaNetwork
  Client->>update_token: UpdateTokenParams
  update_token->>TokenUpdateTransaction: Build update fields
  update_token->>TokenUpdateTransaction: Execute transaction
  TokenUpdateTransaction->>HederaNetwork: Submit token update
  HederaNetwork-->>update_token: Receipt status
  update_token-->>Client: UpdateTokenResponse
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and matches the main change: adding UpdateToken support.
Description check ✅ Passed The description clearly describes the updateToken endpoint and related parameter, response, and handler changes.
Linked Issues check ✅ Passed The PR implements the updateToken handler and the required params/response models for #2397.
Out of Scope Changes check ✅ Passed The changes stay focused on updateToken support and related token transaction plumbing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
📋 Issue Planner

Built with CodeRabbit's Coding Plans for faster development and fewer bugs.

View plan used: #2397

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 71fedbdb-d60d-489d-b015-8e667cf0ac3e

📥 Commits

Reviewing files that changed from the base of the PR and between 3b976da and 42d17d4.

📒 Files selected for processing (3)
  • tck/handlers/token.py
  • tck/param/token.py
  • tck/response/token.py

Comment thread tck/handlers/token.py Outdated
@aceppaluni aceppaluni added reviewer: maintainer PR needs a review from the maintainer team reviewer: committer request review help from a committer and removed approved Issue has been approved by team member labels Jul 22, 2026
@aceppaluni
aceppaluni requested a review from manishdait July 22, 2026 19:08
@github-actions github-actions Bot added open to community review PR is open for community review and feedback queue:junior-committer PR awaiting initial quality review labels Jul 22, 2026
Signed-off-by: aceppaluni <aceppaluni@gmail.com>
@github-actions github-actions Bot added the approved Issue has been approved by team member label Jul 22, 2026
@github-actions github-actions Bot added queue:committers PR awaiting committer technical review and removed queue:junior-committer PR awaiting initial quality review labels Jul 22, 2026

@manishdait manishdait left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aceppaluni, small change request, rest looks good

Comment thread tck/handlers/token.py
transaction = TokenUpdateTransaction().set_grpc_deadline(DEFAULT_GRPC_TIMEOUT)

if params.tokenId is not None:
transaction.set_token_id(TokenId.from_string(params.tokenId))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to remove the fail fast check for token id in the TokenUpdateTransaction _build_proto_body()

Comment thread tck/handlers/token.py
if params.adminKey is not None:
transaction.set_admin_key(get_key_from_string(params.adminKey))

if params.kycKey is not None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also some tck tests pass a keyList with an empty list of keys, which is valid. however, current generate_key currently has this check:

if params.type in {KeyType.THRESHOLD_KEY, KeyType.LIST_KEY} and not params.keys:
        raise JsonRpcError.invalid_params_error(
            "invalid parameters: keys must be provided for keyList or thresholdKey types."
        )

if params.type in {KeyType.THRESHOLD_KEY, KeyType.LIST_KEY} and not params.keys:

since not params.keys is also True for an empty list, it raises an error for a valid input.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should check for the pramas.keys is None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Issue has been approved by team member open to community review PR is open for community review and feedback queue:committers PR awaiting committer technical review reviewer: committer request review help from a committer reviewer: maintainer PR needs a review from the maintainer team scope: TCK involves engineering for the implementation of TCK method and module skill: advanced requires knowledge of multiple areas in the codebase without defined steps to implement or examples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add updateToken endpoint to tck module

4 participants